package com.maozw.api.gateway.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.RoutesRefreshedEvent;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

/**
 * @author MAOZW
 * @Description: ${todo}
 * @date 2018/8/22 11:23
 */

@Service
public class RefreshRouteService {

    @Autowired
    RouteLocator routeLocator;

    @Autowired
    ApplicationEventPublisher applicationEventPublisher;

    public void refreshRoute() {
        RoutesRefreshedEvent routesRefreshedEvent = new RoutesRefreshedEvent(routeLocator);
        applicationEventPublisher.publishEvent(routesRefreshedEvent);
    }
}
